package net.ikenway.springboot.demo.Model.Entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author MasterKenway <zk@ikenway.net>
 * @Description
 * @date Created Date 12/10/2020
 */
@Entity
@DynamicUpdate
@Data
@Table(name = "order_subs")
@NoArgsConstructor
@AllArgsConstructor
public class OrderSub implements Serializable {
    public enum Additions {
        None,
        PUDDING,
        PEARL
    };

    public enum Scale {
        MEDIUM,
        LARGE
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long orderSubId;

    @ManyToOne(targetEntity = Product.class)
    @JoinColumn(name = "product_id")
    private Product product;

//    private Integer number;

    private BigDecimal disCount;
    private BigDecimal actualPrice;

    @Enumerated(EnumType.STRING)
    private Additions additions;

    @Enumerated(EnumType.STRING)
    private Scale scale;

    @Transient
    @ManyToOne(targetEntity = Order.class)
    @JoinColumn(name = "order_id")
    private Order order;
}
